// ==UserScript==
// @name         隐藏图片
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  try to take over the world!
// @author       Yours-bald-zhangsan
// @include        *
// @grant        unsafeWindow
// ==/UserScript==
;(function () {
  'use strict'

  let div = document.createElement('div')
  let span = document.createElement('span')
  let label = document.createElement('label')
  span.innerText = '隐藏图片'
  label.append(span)
  div.appendChild(label)
  div.style.position = 'fixed'
  div.style.top = '0'
  div.style.right = '0'
  div.style.zIndex = 10000
  span.style.cursor = 'pointer'
  document.body.appendChild(div)
  div.addEventListener('click', evt => {
    let imgs = Array.from(document.querySelectorAll('img'))
    if (imgs.some(item => item.style.display != 'none')) {
      span.innerText = '显示图片'
      imgs.forEach(item => {
        if (item.style.display != 'none') {
          item.dataset.display = item.style.display
          item.style.display = 'none'
        }
      })
    } else {
      span.innerText = '隐藏图片'
      imgs.forEach(item => {
        item.style.display = item.dataset.display
      })
    }
  })
})()
